package org.iteam.xlz.manager.action.ad;



import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.iteam.web.shiro.ShiroUtil;
import org.iteam.web.struts.action.AbstractModuleAction;
import org.iteam.web.struts.action.RestAction;
import org.iteam.xlz.core.entity.ad.AdPosVo;
import org.iteam.xlz.core.service.ad.AdPosService;

@SuppressWarnings("unchecked")
@Results({@Result(name="INDEX",type="freemarker",location="/WEB-INF/content/ad/pos/index.html"),
		  @Result(name="EDIT",type="freemarker",location="/WEB-INF/content/ad/pos/edit.html")})
public class AdPosAction extends AbstractModuleAction<AdPosVo> implements RestAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8673733062641661333L;
	private final String PATH="/ad/pos";
	@Override
	public AdPosVo getModel() {
		if(null==model){
			model=new AdPosVo();
		}
		return model;
	}

	@Override
	@Action(PATH+"/index")
	public String index() {
		return INDEX;
	}

	@Override
	@Action(PATH+"/query")
	public String query() {
		map.put("total",AdPosService.getInstance().counts());
		map.put("rows",AdPosService.getInstance().query(page,rows));		
		return MAP;
	}

	@Override
	@Action(PATH+"/create")
	public String create() {
		model.setCreator(ShiroUtil.currentAccount());
		map.put("state",AdPosService.getInstance().create(model));
		return MAP;
	}

	@Override
	@Action(PATH+"/update")
	public String update() {
		map.put("state",AdPosService.getInstance().update(model));
		return MAP;
	}

	@Override
	@Action(PATH+"/{_id}/delete")
	public String delete() {
		map.put("state",AdPosService.getInstance().delete(_id));
		return MAP;
	}

	@Override
	public String destroy() {
		return null;
	}

	@Override
	@Action(PATH+"/{_id}/edit")
	public String edit() {
		object=AdPosService.getInstance().findById(_id);
		map.put("width", 0);
		map.put("height", 0);
		return EDIT;
	}

	@Override
	@Action(PATH+"/new")
	public String editNew() {
		return EDIT;
	}

	@Override
	public String show() {
		return null;
	}
	
	@Action(PATH+"/posType")
	public String getPosType(){
		array = AdPosService.getInstance().getPosType();
		return ARRAY;
	}
	
	@Action(PATH+"/getAdPosInfoList")
	public String getAdPosInfoList(){
		array = AdPosService.getInstance().getAdPosInfoList();
		return ARRAY;
	}
}
